﻿@model Apps.Models.Flow.FlowStateCountModel
@using Apps.Web.Core;
@using Apps.Common;
@using Apps.Models.Sys;
@using Apps.Locale;
@using Apps.Models.Enum;
@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Index_Layout.cshtml";
    List<permModel> perm = null;
}
<div class="mvctool" style="line-height:30px; text-align:right;padding-right:30px;">
    <span class='ml10'>我的申请</span>（@Model.requestCount）
        <span class='color-blue ml10 fa fa-circle'> 审核中</span>（@Model.processCount）
        <span class='color-green ml10 fa fa-circle'> 审核通过（@Model.passCount）</span>
        <span class='color-red ml10 fa fa-circle'> 驳回（@Model.rejectCount）</span>
        <span class='color-gray ml10 fa fa-circle'> 过期（@Model.closedCount）</span>
</div>
<table id="List"></table>

<div id="modalwindow" class="easyui-window" data-options="modal:true,closed:true,minimizable:false,shadow:false"></div>
@Html.Partial("~/Views/Shared/_Partial_AutoGrid.cshtml")
<script type="text/javascript">
    $(function () {
        $('#List').datagrid({
            url: '@Url.Action("GetListByUserId")',
            width:SetGridWidthSub(10),
            methord: 'post',
            height:  SetGridHeightSub(37),
            fitColumns: true,
            sortName: 'CreateTime',
            sortOrder: 'desc',
            idField: 'Id',
            pageSize: 15,
            pageList: [15, 20, 30, 40, 50],
            pagination: true,
            striped: true, //奇偶行是否区分
            singleSelect: true,//单选模式
            rownumbers: true,//行号
            columns: [[
                { field: 'Id', title: 'ID', width: 80,hidden:true },
                { field: 'Title', title: '标题', width: 280,sortable:true },
                { field: 'UserId', title: '发起用户', width: 80, sortable: true, hidden: true },
                { field: 'FormId', title: '对应表单', width: 80, sortable: true, hidden: true },
                { field: 'FormLevel', title: '公文级别', width: 80,sortable:true, hidden: true  },
                { field: 'CreateTime', title: '创建时间', width: 110,sortable:true },
                { field: 'TimeOut', title: '截至时间', width: 80, sortable: true, formatter: function (value) { return SubStrYMD(value) } },
                { field: 'CurrentStep', title: '当前环节', width: 80, sortable: true, align: 'center' },
                {
                    field: 'CurrentState', title: '当前状态', width: 80, sortable: true, align: 'center',
                    formatter: function (value, row, index) {
                        var _pass = "<span class='label label-green'>已通过</span>";
                        var _progress = "<span class='label label-blue'>进行中</span>";
                        var _reject = "<span class='label label-red'>被驳回</span>";
                        var _close = "<span class='label label-gray'>已过期</span>";
                        if(value==@((int)FlowStateEnum.Pass)){ return _pass;}
                        if(value==@((int)FlowStateEnum.Progress)){ return _progress;}
                        if(value==@((int)FlowStateEnum.Reject)){ return _reject;}
                        return _close;
    }

    },
    { field: 'Action', title: '操作', width: 80, sortable: true, align: 'center',formatter:function(value,row,index){
        return "<a href='#' title='管理'  onclick='ManageFlow(\"" + row.Title + "\",\"" + row.FormId + "\",\"" + row.Id + "\",\"" + row.IsExternal + "\")'>管理</a> | <a href='#' title='图例'  onclick='LookFlow(\"" + row.FormId + "\",\"" + row.Id + "\")'>图例</a>";
    }}
    ]]
    });
    });
    //ifram 返回
    function frameReturnByClose() {
        $("#modalwindow").window('close');
    }
    function frameReturnByReload(flag) {
        if (flag)
            $("#List").datagrid('load');
        else
            $("#List").datagrid('reload');
    }
    function frameReturnByMes(mes) {
        $.messageBox5s(Lang.Tip, mes);
    }
    function LookFlow(formId,contentId)
    {
        $("#modalwindow").html("<iframe width='100%' height='100%' scrolling='auto' frameborder='0' src='@Url.Action("Details")?id=" + formId + "&contentId="+contentId+"&Ieguid=" + GetGuid() + "'></iframe>");
                $("#modalwindow").window({ title: '图例', width: 500, height: 380, iconCls: 'fa fa-list' }).window('open');
    }
    function ManageFlow(winTitle, formId, id,IsExternal)
    {
       var url = "@Url.Action("Edit")?formId=" + formId + "&id=" + id + "&Ieguid=" + GetGuid() + "";
       if(IsExternal=="true")
       {
           url = "@Url.Action("EditExternal")?formId=" + formId + "&id=" + id + "&Ieguid=" + GetGuid() + "";
       }
       
        $("#modalwindow").html("<iframe width='100%' height='100%' scrolling='auto' frameborder='0'' src='"+url+"'></iframe>");
        $("#modalwindow").window({ title: winTitle, width:  SetGridWidthSub(10), height: SetGridHeightSub(10), iconCls: 'fa fa-file-text-o' }).window('open');
    }

</script>
